package mvc.proxy
{
	import com.maliu.utils.HashMap;
	import mvc.model.DataModel;
	/**
	 * @author maliu
	 */
	public class DataProxy
	{
		[Embed(source = "../config/textConfig.xml", mimeType = "application/octet-stream")]
		private var DataXMLRef:Class;
		private var m_xml:XML;
		
		private var m_modelList:Vector.<DataModel>;
		
		private var m_hashMapAttack:HashMap;
		private var m_hashMapDefense:HashMap;
		private var m_hashMapUniversal:HashMap;
		
		private static const TYPE_ATTACK:int = 10;
		private static const TYPE_DEFENSE:int = 20;
		private static const TYPE_UNIVERSAL:int = 30;
		
		public function DataProxy()
		{
			m_hashMapAttack = new HashMap();
			m_hashMapDefense = new HashMap();
			m_hashMapUniversal = new HashMap();
			initData();
		}
		
		public function initData():void
		{
			if(m_xml)
				return;
			m_xml = XML(new DataXMLRef());
			var t_attackList:XMLList = m_xml.child("attack");
			var t_defenseList:XMLList = m_xml.child("defense");
			var t_universalList:XMLList = m_xml.child("universal");
			
//			trace(t_attackList.children().length());
//			trace(t_attackList.children().length());
			var t_dataModel:DataModel;
			var t_item:XML;
			for each(t_item in t_attackList.children())
			{
				t_dataModel = new DataModel(DataProxy.TYPE_ATTACK, t_item);
				m_hashMapAttack.put(t_dataModel.id, t_dataModel);
			}
			trace(m_hashMapAttack.length());
			trace(JSON.stringify((m_hashMapAttack.getValue(13) as DataModel).contentList[0]));
//			for each(t_item in t_defenseList.children())
//			{}
//			for each(t_item in t_universalList.children())
//			{}
		}
	}
}
